﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ankha;
using Ankha.ContentPipeline;
using Microsoft.Xna.Framework.Graphics;

namespace ScarletCore.PipelineExtention
{
    public class AssetLibrary : IPipelineExtention
    {
        private static AssetLibrary _Instance;
        public static AssetLibrary Instance
        {
            get
            {
                if (_Instance == null)
                    _Instance = new AssetLibrary();

                return _Instance;
            }
        }

        //Fields
        public string Name { get { return "AssetLibrary"; } }
        private Dictionary<string, Texture2D> _TextureLibrary;

        //Methods
        public void AddTexture(string name)
        {
            try
            {
                Texture2D texture = ScreenManager.GameBase.Content.Load<Texture2D>("src/" + name);
                _TextureLibrary.Add(name, texture);
                ScreenManager.DebugLogInstance.WriteString(string.Format("Loaded asset 'src/{0}' in {1}", name, this.GetType().Namespace));
            }
            catch (Exception)
            {
                ScreenManager.DebugLogInstance.WriteString(string.Format("Exception loading asset 'src/{0}' in {1}", name, this.GetType().Namespace));
            }
        }
        public void Load()
        {
            _TextureLibrary = new Dictionary<string, Texture2D>();
            AddTexture("ASSET_SHIP");
        }
    }
}
